
        /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package oscilloscope;

import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author francispapineau
 */
public class SplitParseAnalog {

    /*________________________________________________________________________________*/

    private static String REGEX1 = "[AZeOnTwohrFiv:]";
    static public int i = 0, count = 0, j = 0;
    static public String One = "", Two = "", Three = "", Four = "", Five = "";
    static public float Num1 = (float) 0.00, Num2 = (float) 0.00, Num3 = (float) 0.00, Num4 = (float) 0.00, Num5 = (float) 0.00;

   /*________________________________________________________________________________*/


    static public void splitVal(String Val) throws IOException{
        count++;
        Pattern p = Pattern.compile(REGEX1);
        String[] items = p.split(Val);
        
        for(String s : items) {
            if (i == 5){
                One = items[5];
                if (One != null && !One.isEmpty()){
                    Num1 = Float.parseFloat(One);
                    System.out.println(Num1);
                    oscilloscope.OscilloscopeView.pin1.setText(One);
                }
            }
            else if (i == 9){
                Two = items[9];
                if (Two != null && !Two.isEmpty()){
                    Num2 = Float.parseFloat(Two);
                    oscilloscope.OscilloscopeView.pin2.setText(Two);

                }

            }
            else if (i == 13){
                Three = items[13];
                if (Three != null && !Three.isEmpty()){
                    Num3 = Float.parseFloat(Three);
                    oscilloscope.OscilloscopeView.pin3.setText(Three);

                }
            }
            else if (i == 17){
                Four = items[17];
                if (Four != null && !Four.isEmpty()){
                    Num4 = Float.parseFloat(Four);
                    oscilloscope.OscilloscopeView.pin4.setText(Four);

                }
            }
            else if (i == 21){
                Five = items[21];
                if (Five != null && !Five.isEmpty()){
                    Num5 = Float.parseFloat(Five);
                    oscilloscope.OscilloscopeView.pin5.setText(Five);

                }
            }
            i++;
        }
        i = 0;
    }

       /*________________________________________________________________________________*/

    public static boolean parsable(String val){

        Pattern p = Pattern.compile("(A)(Zer:)(\\d+)(.)(\\d+)(One:)(\\d+)(.)(\\d+)(Two:)(\\d+)(.)(\\d+)(Thr:)(\\d+)(.)(\\d+)"
                + "(For:)(\\d+)(.)(\\d+)(Fiv:)(\\d+)(.)(\\d+)");
        Matcher m = p.matcher(val);

        if (m.find()){
            System.out.print("y");
            return true;
        }
        else{
            System.out.print("n");
            return false;
        }
    }

}
